// ComboDialog.cpp

#include "StdAfx.h"
#include "ComboDialog.h"

#ifdef LANG
#include "Common/Lang/LangUtils.h"
#endif

using namespace Common;

#ifdef LANG
static Lang::CIDLangPair kIDLangPairs[] =
{
  { IDOK, 0x02000702 },
  { IDCANCEL, 0x02000710 }
};
#endif
LRESULT CComboDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
  #ifdef LANG
  Lang::LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
  #endif
  _comboBox.Attach(GetDlgItem(IDC_COMBO_COMBO));

  SetWindowText(Title);
  
  CStatic staticContol;
  staticContol.Attach(GetDlgItem(IDC_COMBO_COMBO));
  staticContol.SetWindowText(Static);
  _comboBox.SetWindowText(Value);
  for(size_t i = 0; i < Strings.size(); i++)
    _comboBox.AddString(Strings[i]);
   CenterWindow(GetParent());
  return TRUE;
}


LRESULT CComboDialog::OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
{
	int xSize = LOWORD(lParam);
	int ySize = HIWORD(lParam);
  int mx, my;
   RECT rect;
    rect.left = 0;
    rect.top = 0;
    rect.right = 8;
    rect.bottom = 8;
    MapDialogRect(&rect);
     
    mx = rect.right - rect.left;
    my = rect.bottom - rect.top;
   
  int bx1, bx2, by;
  CWindow wndCancel = GetDlgItem(IDCANCEL);
  wndCancel.GetWindowRect(&rect);
  bx1 = rect.right - rect.left;
  by = rect.bottom - rect.top;
  CWindow wndOK = GetDlgItem(IDOK);
  wndOK.GetWindowRect(&rect);
  bx2 = rect.right - rect.left;
  int y = ySize - my - by;
  int x = xSize - mx - bx1;

  InvalidateRect(NULL);
  wndCancel.MoveWindow(x, y, bx1, by);
  wndOK.MoveWindow(x - mx - bx2, y, bx2, by); 
  ChangeSubWindowSizeX(_comboBox, xSize - mx * 2, m_hWnd);
  return 0L;
}

